package com.ad2campaign.engine.utils;

import java.io.IOException;
import java.sql.Connection;
import java.util.Properties;

import org.springframework.jdbc.datasource.DriverManagerDataSource;

public class DatasourceUtil 
{

	public static boolean checkDatasource() throws IOException
	{
		Properties engineEnvironment = PropertyLoader.settings();
		DriverManagerDataSource dataSource = new DriverManagerDataSource();

		try 
		{
			dataSource.setDriverClassName(engineEnvironment.getProperty("batch.jdbc.driver"));
	 		dataSource.setUrl(engineEnvironment.getProperty("batch.jdbc.url"));
			dataSource.setUsername(engineEnvironment.getProperty("batch.jdbc.user"));
			dataSource.setPassword(engineEnvironment.getProperty("batch.jdbc.password"));
 			Connection connection= dataSource.getConnection();
 			connection.getMetaData().toString();
 			connection.close();
 			return true;
		} catch (Exception e) 
		{
			return false;
 		}
		
 
	}
	
}
